using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace SerialPortCommunicationProject
{
    [ValueConversion(typeof(bool), typeof(string))]
    public class IsServerConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool re = (bool)value;
            if (re)
            {
                return "TCP Server";
            }
            else
            {
                return "TCP Client";
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string strValue = value as string;
            if (strValue == "TCP Server")
            {
                return true;
            }
            if (strValue == "TCP Client")
            {
                return false;
            }
            return DependencyProperty.UnsetValue;
        }
    }
}

    
